<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>类型转换</title>
</head>
<body>
  <script>
      /*强制类型转换
      字符串转数字 Number（）方法
      转字符串String 方法
      转bollean bollean方法
      */
      var a = "10asd";
      console.log(Number(a));
      console.log(typeof Number(a));

      var  b= 10;
      console.log(String(10));
      console.log(typeof String(10));

      var c=0
      console.log(Boolean(c));
      console.log(typeof Boolean(c));

      /*
        自动类型转换
        数字转字符 + 拼接""
        字符转数字 字符串- * / % 1
        string 转 boolean无法自动类型转换
        boolean转Number 加减乘除做算术运算自动转成Number true是1 false是0
      */
      var d = 10;
      console.log(d+"");
      console.log(typeof (d+""));

      var d = "12";
      console.log(d-1);
      console.log(typeof (d-1));

      var e = true
      console.log(e - 1);
      console.log(typeof (e - 1));
  </script>
</body>
</html>